mozillafandomcom-20200213-history
Stats Tracking/script planning
< Stats Tracking Introduction This page is for passing around ideas for the different scripts and programs that will go into making this project a reality. The page, Stats/ua script is for writing and discussing the actual code... (This is for theory, that is for practice) Implementations The following is a diagram of how a user-tracking script would work on a remote website... Please remember that we want to make this as portable to as many different platforms as possible, so writing this in PHP, ASP, and any other server-side language as possible will be extremely helpful. Also, the functions to connect to, read from, and write to databases should cover as many different database types as possible, include a raw text file for those who don't want to use a database. Obviously, we will also need an installation script, which I'll cover later. Commentary: The script obviously enters at the top ;-), then is faced with a choice as to whether or not this will be an administrative session or not. (Admin session would be for changing options, displaying stats, etc.) The easiest way to do this would be to use an HTTP GET request, for instance, "myscript.php?admin=yes". If we are counting stats, however, we should then check if the user has visited the site recently, probably by checking the IP to a list of recent IPs... This would imply opening and reading the database before this step... I'll have to update this image to reflect this revelation. :-P Anyways, as we continue, if the user doesn't have an existing session, then we'll get their user agent string, sort the relevant information out of it, and store their information... Along the way, we'll also check our database to see if we have enough records to send up to our central bean-counting server for final processing and display on our web page. Installation I really hope that this gets MUCH more involved as we add different options to the above script... The installation is the key to making the script as cross-platform compliant as possible. Commentary: The script enters, and is faced with figuring out if the variables that it needs are set or not... Obviously, if the variables aren't set, then the user will have to assign them, so we go onto the right side of the script where we display a web page with a whole bunch of input fields, (and possibly javascript to hide unnecessary input fields?) and a submit button. Once the submit button is pressed, the page is redirected to itself with a bunch of POST data, and we run down the left side of this diagram, where we do all of the actual configuration, such as setting up the database, optimizing the tracking script, etc. Some ideas for options that I've thought of are in the image. Functions Needed We will need the following functions for the stat tracker: *Display Administrative Page (Mostly echo HTML) **Possible Login **Show stats, either raw or graphical **Allow to change settings, such as database connection info and site name *Open Database, Select from, and update **As many DB types as possible (We have MySQL) *Send stored records **via Email **via RSS? **via HTTP POST request? (might require more than just scripting) Following functions for installation script: *HTML/Javascript for the configuration options **Javascript would hide input fields that are not necessary, i.e., if a webmaster selects to use a plaintext file for storage, a database name and password wouldn't be needed. *Optimize stat tracking script **remove database types that were not selected **remove password sub-page for admins who are alright with stats being public **etc... in other words, we're completely re-writing a custom stat tracking script *Set up database fields *Confirmation web page (again, just echoing HTML... I can make it work, but I'm not that great at making it look professional) Existing Functions We already have these functions available for the stat tracker using PHP... Everyone is still welcome to post these functions using different server-side languages. *Determine User_Agent **Thank you, Kincera *DB Connect to MySQL **Thank you, Kincera *Write to plaintext file *Optional image passing function **For those who can't/won't include the stat tracker in their page's scripts Script Planning